﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mime;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace TeachingAffairsManagementSystem
{
    public partial class SiteMaster : MasterPage
    {
        private Control _headNavbar = new Control();
        private Control _mainNavbar = new Control();

        private void Page_Init(object sender, EventArgs e)
        {
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if ((bool) Session["isLoggedIn"] == false)
            {
                // 未登录
                _headNavbar = LoadControl("~/UserControl/HeadNavbar/NotLoggedInHeadNavbar.ascx");
                _mainNavbar = LoadControl("~/UserControl/MainNavbar/VisitorMainNavbar.ascx");
                PHHeadNavbar.Controls.Add(_headNavbar);
                PHMainNavbar.Controls.Add(_mainNavbar);
            }
            else
            {
                _headNavbar = LoadControl("~/UserControl/HeadNavbar/LoggedInHeadNavbar.ascx");
                switch ((string) Session["userType"])
                {
                    case "student":
                        _mainNavbar = LoadControl("~/UserControl/MainNavbar/StudentMainNavbar.ascx");
                        break;
                    case "teacher":
                        _mainNavbar = LoadControl("~/UserControl/MainNavbar/TeacherMainNavbar.ascx");
                        break;
                    case "admin":
                        _mainNavbar = LoadControl("~/UserControl/MainNavbar/AdminMainNavbar.ascx");
                        break;
                }

                PHHeadNavbar.Controls.Add(_headNavbar);
                PHMainNavbar.Controls.Add(_mainNavbar);
            }
        }
    }
}